local ____lualib = require("lualib_bundle")
local __TS__New = ____lualib.__TS__New
local __TS__ArrayForEach = ____lualib.__TS__ArrayForEach
local __TS__SourceMapTraceBack = ____lualib.__TS__SourceMapTraceBack
__TS__SourceMapTraceBack(debug.getinfo(1).short_src, {["7"] = 3,["8"] = 3,["9"] = 4,["10"] = 4,["11"] = 5,["12"] = 5,["13"] = 6,["14"] = 6,["15"] = 7,["16"] = 7,["17"] = 8,["18"] = 8,["19"] = 9,["20"] = 9,["21"] = 12,["22"] = 15,["23"] = 18,["24"] = 21,["25"] = 29,["29"] = 35,["30"] = 36,["31"] = 36,["32"] = 36,["33"] = 37,["34"] = 38,["35"] = 39,["36"] = 40,["37"] = 41,["39"] = 43,["41"] = 45,["42"] = 36,["43"] = 36,["44"] = 35,["45"] = 49,["46"] = 50,["47"] = 51,["48"] = 52,["49"] = 53,["50"] = 53,["51"] = 53,["52"] = 54,["53"] = 53,["54"] = 53,["55"] = 56,["56"] = 57,["57"] = 58,["58"] = 56,["59"] = 60,["60"] = 61,["61"] = 49,["62"] = 64,["63"] = 65,["64"] = 66,["65"] = 66,["66"] = 66,["67"] = 67,["68"] = 68,["69"] = 69,["70"] = 70,["71"] = 71,["72"] = 72,["73"] = 72,["74"] = 72,["75"] = 72,["77"] = 74,["78"] = 74,["79"] = 74,["80"] = 74,["82"] = 66,["83"] = 66,["84"] = 66,["85"] = 64,["86"] = 79,["87"] = 80,["88"] = 79,["89"] = 83});
local ____exports = {}
local ____table = require("kernel.util.table")
local KTable = ____table.default
local ____ui = require("kernel.util.ui")
local KUi = ____ui.default
local ____player_group = require("kernel.util.player_group")
local KPlayerGroup = ____player_group.default
local ____ui = require("data.ui.index")
local UI = ____ui.default
local ____RectAttack = require("kernel.lib.attack.RectAttack")
local RectAttack = ____RectAttack.default
local ____player = require("kernel.util.player")
local KPlayer = ____player.default
local ____rect = require("kernel.util.rect")
local KRect = ____rect.default
local interval = 3
local attackIndex = 0
local monsterCount = 30
local rects = {10003, 10004, 10005, 10006}
local ____table = __TS__New(KTable, "进攻怪")
--- 设置进攻倒计时文本
-- 
-- @param text
local function setAttackTime(____, text)
    __TS__ArrayForEach(
        KPlayerGroup:fromPlaying(),
        function(____, player)
            local ui
            local key = "ui-进攻倒计时"
            if not player:hasData(key) then
                ui = KUi:searchPath(player, UI.AttackTimerLabel)
                player:setData(key, ui)
            else
                ui = player:getData(key)
            end
            ui:setText(text)
        end
    )
end
local function startAttack()
    local player = KPlayer:fromId(5)
    local typeId = ____table:get({attackIndex, "type"})
    local attack = __TS__New(RectAttack, player, typeId, monsterCount)
    __TS__ArrayForEach(
        rects,
        function(____, rect)
            attack:addRect(__TS__New(KRect, rect))
        end
    )
    attack:onRefresh(function(____, unit)
        unit:setAlarmRange(999999)
        unit:setCancelAlarmRange(999999)
    end)
    attack:setTarget(0, 0)
    attack:start()
end
local function delayAttack(____, time)
    local i = time
    local timerId
    timerId = setInterval(
        function()
            i = i - 1
            if i <= 0 then
                attackIndex = attackIndex + 1
                startAttack(nil)
                clearInterval(timerId)
                setAttackTime(
                    nil,
                    ("第" .. tostring(attackIndex)) .. "波进攻"
                )
            else
                setAttackTime(
                    nil,
                    tostring(i) .. "秒后开始进攻"
                )
            end
        end,
        1000
    )
end
local function InitAttack()
    delayAttack(nil, interval)
end
____exports.default = InitAttack
return ____exports
